package com.wyu.blog.service;

import com.wyu.blog.dao.UserFriendMapper;
import com.wyu.blog.entity.UserFriend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class UserFriendService {

    @Autowired
    private UserFriendMapper userFriendMapper;

    /**
     * 查询所有关注的用户
     * @param userId
     * @return
     */
    public List<UserFriend> findUserConcern(Integer userId) {
        return userFriendMapper.selectUserConcern(userId);
    }

    /**
     * 查询所有粉丝
     * @param userId
     * @return
     */
    public List<UserFriend> findUserFans(Integer userId) {
        return userFriendMapper.selectUserFans(userId);
    }

    /**
     * 查询用户关注的数量
     * @param userId
     * @return
     */
    public Integer findConcernNum(Integer userId) {
        return userFriendMapper.selectConcernNum(userId);
    }

    /**
     * 查询用户粉丝的数量
     * @param userId
     * @return
     */
    public Integer findFansNum(Integer userId) {
        return userFriendMapper.selectFansNum(userId);
    }

    /**
     * 关注用户
     * @param userFriend
     * @return
     */
    public Integer addUserConcern(UserFriend userFriend) {
        return userFriendMapper.insertUserConcern(userFriend);
    }


    public Integer cancelUserConcern(HashMap map) {
        return userFriendMapper.deleteUserConcern(map);
    }
}
